package com.study.a01netAddressDemo;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class MyInetAddressDemo1 {
    public static void main(String[] args) throws UnknownHostException {

        //获取inetAddress对象
        //确定主机名称的IP地址。可以是ip也可以是机器名称
      InetAddress address=InetAddress.getByName("LAPTOP-287PC8Q5");
        System.out.println(address);

        String name=address.getHostName();
        System.out.println(name);

        String ip=address.getHostAddress();
        System.out.println(ip);

    }
}
